<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div style="width:100%;text-align: center">
  <form>
    <div style="padding-top: 5em;padding-left: 5em;padding-right: 5em">
      <h1 style="font-size: 3rem" >本页面为采集浏览器信息，点击下方按扭发送给上级管理员</h1>

      <button type="button" id="copy" onclick="copyInfo()" style="margin-top: 7em"  class="ant-btn ant-btn-red">复制浏览器信息</button>

    </div>
    <div style="margin-top: 2em;">
      <span id="errorMessage" style="display: none;color:red;font-size: 1.5rem">复制失败</span>
    </div>
  </form>
</div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/fingerprintjs2@2.1.0/dist/fingerprint2.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/simple-crypto-js@latest/dist/SimpleCrypto.min.js"></script>
<script type="text/javascript">

  var demon = "www.fashiontiy.com";
  var simpleCrypto = new SimpleCrypto(demon);
  var errorMessage = document.getElementById("errorMessage");
  errorMessage.style.display = "none";
  var options = {
    excludes : {
      //deviceMemory: true,
      webglVendorAndRenderer: true,
      //adBlock: true,
      enumerateDevices:true,
      availableScreenResolution: true
    }
  };

  var finger = "";
  var userAgent = "";
  Fingerprint2.get(options,(components) => {
    var values = components.map( (component) => { return component.value });
    userAgent = components[0].value;
    finger = Fingerprint2.x64hash128(values.join(demon), 31);
    console.log(components);
    console.log(finger);

  });

  function copyInfo() {
    var tag = document.createElement('input');
    tag.setAttribute('id', 'cp_hgz_input');
    if (userAgent == "" && finger == ""){
      errorMessage.innerHTML = "复制失败,请刷新后重试";
      errorMessage.style.display = "";
      return;
    }
    tag.value = simpleCrypto.encrypt(userAgent + "---" + finger);
    document.getElementsByTagName('body')[0].appendChild(tag);
    document.getElementById('cp_hgz_input').select();
    document.execCommand('copy');
    document.getElementById('cp_hgz_input').remove();
    document.getElementById("errorMessage").innerHTML = "复制成功";
    errorMessage.style.display = "";
  }
</script>
<style>
  .ant-btn {
    line-height: 1.499;
    position: relative;
    display: inline-block;
    font-weight: 400;
    white-space: nowrap;
    text-align: center;
    background-image: none;
    border: 1px solid transparent;
    -webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.015);
    box-shadow: 0 2px 0 rgba(0,0,0,0.015);
    cursor: pointer;
    -webkit-transition: all .3s cubic-bezier(.645, .045, .355, 1);
    transition: all .3s cubic-bezier(.645, .045, .355, 1);
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -ms-touch-action: manipulation;
    touch-action: manipulation;
    height: 3em;
    padding: 0 3em;
    font-size: 1.8rem;
    border-radius: 4px;
    color: rgba(0,0,0,0.65);
    background-color: #fff;
    border-color: #d9d9d9;
  }

  .ant-btn-red {
    color: #fff;
    background-color: #FF5A44;
    border-color: #FF5A44;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.12);
    -webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.045);
    box-shadow: 0 2px 0 rgba(0,0,0,0.045);
  }

</style>
</body>
</html>
